package com.gene.utils;

import java.awt.*;
import java.net.InetAddress;
import java.net.UnknownHostException;

/**
 * 获取本机ip （可以删除）
 */
public class ThisIp {
    public static void main(String[] args) {
        InetAddress ia=null;
        try {
            ia = ia.getLocalHost();
            String localname=ia.getHostName();
            String localip=ia.getHostAddress();
            System.out.println("本机名称是："+ localname);
            System.out.println("本机的ip是 ："+localip);
            getScreen();
        } catch (UnknownHostException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    }



    //获取电脑屏幕信息
    public static void getScreen()
    {
        Dimension screensize   =   Toolkit.getDefaultToolkit().getScreenSize();
        int width = (int)screensize.getWidth();
        int height = (int)screensize.getHeight();
        System.out.println("宽的像素："+width+"高的像素："+height);
        //获取屏幕的dpi
        int dpi = Toolkit.getDefaultToolkit().getScreenResolution();
        System.out.println(dpi);
        //根据dpi和像素，可以计算物理尺寸
        System.out.println("宽："+width/dpi+"高："+height/dpi);
    }
}
